﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.ServiceProcess;
using SrvMgr;

namespace winApp2
{
    public partial class Form4 : Form
    {
        public Form4()
        {
            InitializeComponent();
        }

        private void Form4_Load(object sender, EventArgs e)
        {

            int n = 0;
            int m = 0;
            ServiceController[] scs = ServiceController.GetServices();
            foreach (var sc in scs)
            {
                string name = sc.ServiceName.ToUpper();
                if ((name.StartsWith("MSSQL") && !name.Contains("HELP")
                    && !name.Contains("OLAP")
                    && !name.Contains("LFDL")))
                {
                    ucSrvMgr usm = new ucSrvMgr();
                    usm.ServiceName = sc.ServiceName;
                    usm.Left = 5;
                    usm.Top = n * 135 + 5;
                    this.Controls.Add(usm);
                    n++;
                }

                if ((
                     name.StartsWith("ORACLE") && !name.Contains("JOB") && !name.Contains("CONSOLE") && !name.Contains("ISQL*PLUS")
                    ))
                {
                    ucSrvMgr usm = new ucSrvMgr();
                    usm.ServiceName = sc.ServiceName;
                    usm.Left = 5 + usm.Width;
                    usm.Top = m * 135 + 5;
                    this.Controls.Add(usm);
                    m++;
                }
            }
            this.Width = 200 + ((m > 0) ? 200 : 0);
            int max = m;
            if (n > m) max = n;
            this.Height = 135 * max + 30;
        }
    }
}
